  #ifndef SERVER_H
#define SERVER_H

#include <QTimer>
#include <QMutex>

#include "urg/UrgCtrl.h"
#include "urg/RangeSensorParameter.h"

#include "sensor/Laser.h"
#include "sensor/Camera.h"

#include "sensor/MJPEGClient.h"
#include "sensor/RS232Motor.h"

#include "qdisplay/ImageViewer.h"
#include "qdisplay/GILaserScan.h"

using namespace qrk;

class RobotMotor;

class Server : public QWidget
{
    Q_OBJECT

public:    
    Server();
    ~Server();

    void initialize();
    void run();
    void stop();
    void displayData();

public slots:
    void gotNewSensorData( const QImage* pic );
    void gotNewSensorData( const RS232Data* sensorL, const RS232Data* sensorR );
    void gotNewSensorData( vector<long> laserdata, const long timeStamp );

    void getRobotData();
    void setWheelsSpeed( const char speed1, const char speed2 );
    void getLaserData();


private:  
    void initThreadVideo();
    void initThreadMotor();
    void initThreadLaser();

    void runThreadVideo();
    void runThreadMotor();
    void runThreadLaser();

    long getCurrentTime();

    MJPEGClient* m_mjpegClient;
    ImageViewer* m_cameraViewer;
    CameraData m_camera;

    RS232Motor m_controller;
    RS232Data m_dataL;
    RS232Data m_dataR;
    int m_hCOM;

    UrgCtrl m_urg;
    RangeSensorParameter m_urg_params;
    LaserData m_laser;

    GILaserScan* m_laserViewer;

    QGraphicsScene* m_scene;
    QGraphicsView* m_view;

    //QMutex m_mutex;

};

#endif // SERVER_H
